<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理</title>
</head>

<body>
<?php
include("conn.php");			//包含conn.php文件
if(isset($_POST['id']) and isset($_POST['Submit']) and $_POST['Submit']=="删除"){
      $delete=mysql_query("delete from tb_news where id='".$_POST['id']."'",$conn);
      if($delete){
	echo  "<script> alert('删除成功!');   window.location.href='backstage.php'</script>";
      }else{
	echo  "<script> alert('删除失败!'); window.location.href='backstage.php'</script>";
      }
}
?>
<?php
include("conn.php");		//包含conn.php文件
if(isset($_POST['name']) && $_POST['name']!=""){//判断用户名是否存在
$sql=("insert into tb_user(name,pwd,sex,email) values('".$_POST['name']."','".$_POST['pwd']."','".$_POST['sex']."','".$_POST['email']."')");	
$result=mysql_query($sql,$conn);		//执行添加操作
	if($result){				//判断是否执行成功
	echo  "<script> alert('注册成功!'); window.location.href='backstage.php'</script>";
	}else{
	echo  "<script> alert('注册失败!'); window.location.href='backstage.php'</script>";
	}
}
?>
<?php
include("conn.php");			//包含conn.php文件
$select=mysql_query("select * from tb_user where name='".$_POST['name']."' and pwd='".$_POST['pwd']."'",$conn);
if(isset($_POST['Submit']) and $_POST['name']!=null and $_POST['pwd']!=null){
	if(mysql_num_rows($select)==1){
		echo "<script> alert('登录成功!'); window.location.href='backstage.php'</script>";
	}else{
		echo  "<script> alert('登录失败!'); window.location.href='backstage.php'</script>";
	}
}
?>
<?php
include("conn.php");		//包含conn.php文件
$select=mysql_query("select * from tb_user",$conn);  //执行查询操作，并返回查询结果
?>
<?php
    while($rows=mysql_fetch_array($select)){  //使用while循环输出查询结果
?>
    <tr><td><div align="center"><?php echo $rows['name'];?> </div></td>
          <td><div align="center"><?php echo $rows['sex'];?></div></td>
          <td><div align="center"><?php echo $rows['email'];?></div></td>
    </tr>
<?php
	}			//结束while循环
?>


</body>
</html>